package learn.cwebsitelearn.chapter8;

import java.util.Objects;

/**
 * @AUTHOR LYF
 * @DATE 2022/3/27
 * @VERSION 1.0
 * @DESC
 */

abstract class AbstractClass{
    public AbstractClass(String param){
    }



}
class NonClass{
    public NonClass(){

    }
    public NonClass(String param){

    }
}
class SubClass1 extends NonClass{
    public SubClass1(int i){
//        super("");


    }
}
class SubClass2 extends AbstractClass{

//    public SubClass2(String param) {
//        super(param);
//    }

    public SubClass2(){
        super("");
        // super("");
    }

}


class Person{
    private int age;
    private String name;

    public Person(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
//        if (this == o) return true;
//        if (o == null || getClass() != o.getClass()) return false;
//        Person person = (Person) o;
//        return age == person.age && Objects.equals(name, person.name);
        System.out.println("equal"+this.hashCode()+":"+o.hashCode());
//        if(this.hashCode()==o.hashCode())
//            return true;
//        else
//            return false;
        if(this.name.equals(((Person)o).name))
            return true;
        else
            return false;
    }


    @Override
    public int hashCode() {
        System.out.println(Objects.hash(age, name));
        return Objects.hash(age, name);
    }
}
public class AbstractDemo {


    private int a,b;
    void method(int aa,int bb ){
        a=aa--;
        b=aa*bb;
    }


    public static void main(String[] args) {


        AbstractDemo a = new AbstractDemo();//.method();
        a.method(4,5);
        System.out.println(a.a+";"+a.b);

//        new SubClass1(1);
//        Person person1 = new Person(10,"h");
//        Person person2 = person1;
//        System.out.println(person1==person2);
//        System.out.println(person1.equals(person2));
//        System.out.println(person1+":"+person2);
//        change(person2);
//        System.out.println(person1==person2);
//        System.out.println(person1.equals(person2));
//        System.out.println(person1+":"+person2);

    }
    static void change(Person p){
        p.setName("hello");
    }

}
